Api
EOSIO Javascript / Exports / Api
Class: Api
Table of contents
Constructors
Properties
- abiProvider
- abiTypes
- authorityProvider
- cachedAbis
- chainId
- contracts
- rpc
- signatureProvider
- textDecoder
- textEncoder
- transactionTypes
Methods
- deserialize
- deserializeActions
- deserializeTransaction
- deserializeTransactionWithActions
- getAbi
- getCachedAbi
- getContract
- getTransactionAbis
- pushSignedTransaction
- rawAbiToJson
- sendSignedTransaction
- sendSignedTransaction2
- serialize
- serializeActions
- serializeContextFreeData
- serializeTransaction
- transact
Constructors
constructor
• new Api(args
)
Parameters
Name | Type | Description |
---|---|---|
args | Object | rpc : Issues RPC calls authorityProvider : Get public keys needed to meet authorities in a transaction abiProvider : Supplies ABIs in raw form (binary) signatureProvider : Signs transactions chainId : Identifies chain textEncoder : TextEncoder instance to use. Pass in null if running in a browser * textDecoder : TextDecoder instance to use. Pass in null if running in a browser |
args.abiProvider? | AbiProvider | - |
args.authorityProvider? | AuthorityProvider | - |
args.chainId? | string | - |
args.rpc | JsonRpc | - |
args.signatureProvider | SignatureProvider | - |
args.textDecoder? | TextDecoder | - |
args.textEncoder? | TextEncoder | - |
Defined in
src/eosjs-api.ts:64
Properties
abiProvider
• abiProvider: AbiProvider
Supplies ABIs in raw form (binary)
Defined in
src/eosjs-api.ts:25
abiTypes
• abiTypes: Map
<string
, Type
>
Converts abi files between binary and structured form (abi.abi.json
)
Defined in
src/eosjs-api.ts:37
authorityProvider
• authorityProvider: AuthorityProvider
Get subset of availableKeys
needed to meet authorities in a transaction
Defined in
src/eosjs-api.ts:22
cachedAbis
• cachedAbis: Map
<string
, CachedAbi
>
Fetched abis
Defined in
src/eosjs-api.ts:46
chainId
• chainId: string
Identifies chain
Defined in
src/eosjs-api.ts:31
contracts
• contracts: Map
<string
, Contract
>
Holds information needed to serialize contract actions
Defined in
src/eosjs-api.ts:43
rpc
• rpc: JsonRpc
Issues RPC calls
Defined in
src/eosjs-api.ts:19
signatureProvider
• signatureProvider: SignatureProvider
Signs transactions
Defined in
src/eosjs-api.ts:28
textDecoder
• textDecoder: TextDecoder
Defined in
src/eosjs-api.ts:34
textEncoder
• textEncoder: TextEncoder
Defined in
src/eosjs-api.ts:33
transactionTypes
• transactionTypes: Map
<string
, Type
>
Converts transactions between binary and structured form (transaction.abi.json
)
Defined in
src/eosjs-api.ts:40
Methods
deserialize
▸ deserialize(buffer
, type
): any
Convert data in buffer
to structured form. type
must be a built-in abi type or in transaction.abi.json
.
Parameters
Name | Type |
---|---|
buffer | SerialBuffer |
type | string |
Returns
any
Defined in
src/eosjs-api.ts:162
deserializeActions
▸ deserializeActions(actions
): Promise
<Action
[]>
Convert actions from hex
Parameters
Name | Type |
---|---|
actions | Action [] |
Returns
Promise
<Action
[]>
Defined in
src/eosjs-api.ts:211
deserializeTransaction
▸ deserializeTransaction(transaction
): any
Convert a transaction from binary. Leaves actions in hex.
Parameters
Name | Type |
---|---|
transaction | Uint8Array |
Returns
any
Defined in
src/eosjs-api.ts:195
deserializeTransactionWithActions
▸ deserializeTransactionWithActions(transaction
): Promise
<any
>
Convert a transaction from binary. Also deserializes actions.
Parameters
Name | Type |
---|---|
transaction | string | Uint8Array |
Returns
Promise
<any
>
Defined in
src/eosjs-api.ts:220
getAbi
▸ getAbi(accountName
, reload?
): Promise
<Abi
>
Get abi in structured form. Fetch when needed.
Parameters
Name | Type | Default value |
---|---|---|
accountName | string | undefined |
reload | boolean | false |
Returns
Promise
<Abi
>
Defined in
src/eosjs-api.ts:124
getCachedAbi
▸ getCachedAbi(accountName
, reload?
): Promise
<CachedAbi
>
Get abi in both binary and structured forms. Fetch when needed.
Parameters
Name | Type | Default value |
---|---|---|
accountName | string | undefined |
reload | boolean | false |
Returns
Promise
<CachedAbi
>
Defined in
src/eosjs-api.ts:103
getContract
▸ getContract(accountName
, reload?
): Promise
<Contract
>
Get data needed to serialize actions in a contract
Parameters
Name | Type | Default value |
---|---|---|
accountName | string | undefined |
reload | boolean | false |
Returns
Promise
<Contract
>
Defined in
src/eosjs-api.ts:141
getTransactionAbis
▸ getTransactionAbis(transaction
, reload?
): Promise
<BinaryAbi
[]>
Get abis needed by a transaction
Parameters
Name | Type | Default value |
---|---|---|
transaction | any | undefined |
reload | boolean | false |
Returns
Promise
<BinaryAbi
[]>
Defined in
src/eosjs-api.ts:129
pushSignedTransaction
▸ pushSignedTransaction(__namedParameters
): Promise
<any
>
Broadcast a signed transaction using push_transaction RPC
Parameters
Name | Type |
---|---|
__namedParameters | PushTransactionArgs |
Returns
Promise
<any
>
Defined in
src/eosjs-api.ts:365
rawAbiToJson
▸ rawAbiToJson(rawAbi
): Abi
Decodes an abi as Uint8Array into json.
Parameters
Name | Type |
---|---|
rawAbi | Uint8Array |
Returns
Defined in
src/eosjs-api.ts:89
sendSignedTransaction
▸ sendSignedTransaction(__namedParameters
): Promise
<any
>
Broadcast a signed transaction using send_transaction RPC
Parameters
Name | Type |
---|---|
__namedParameters | PushTransactionArgs |
Returns
Promise
<any
>
Defined in
src/eosjs-api.ts:376
sendSignedTransaction2
▸ sendSignedTransaction2(__namedParameters
): Promise
<any
>
Broadcast a signed transaction using send_transaction2 RPC
Parameters
Name | Type |
---|---|
__namedParameters | SendTransaction2Args |
Returns
Promise
<any
>
Defined in
src/eosjs-api.ts:387
serialize
▸ serialize(buffer
, type
, value
): void
Convert value
to binary form. type
must be a built-in abi type or in transaction.abi.json
.
Parameters
Name | Type |
---|---|
buffer | SerialBuffer |
type | string |
value | any |
Returns
void
Defined in
src/eosjs-api.ts:157
serializeActions
▸ serializeActions(actions
): Promise
<SerializedAction
[]>
Convert actions to hex
Parameters
Name | Type |
---|---|
actions | Action [] |
Returns
Promise
<SerializedAction
[]>
Defined in
src/eosjs-api.ts:202
serializeContextFreeData
▸ serializeContextFreeData(contextFreeData
): Uint8Array
Serialize context-free data
Parameters
Name | Type |
---|---|
contextFreeData | Uint8Array [] |
Returns
Uint8Array
Defined in
src/eosjs-api.ts:182
serializeTransaction
▸ serializeTransaction(transaction
): Uint8Array
Convert a transaction to binary
Parameters
Name | Type |
---|---|
transaction | any |
Returns
Uint8Array
Defined in
src/eosjs-api.ts:167
transact
▸ transact(transaction
, __namedParameters?
): Promise
<any
>
Create and optionally broadcast a transaction.
Named Parameters:
broadcast
: broadcast this transaction?sign
: sign this transaction?useOldRPC
: use old RPC push_transaction, rather than new RPC send_transaction?useOldSendRPC
: use old RPC /v1/chain/send_transaction, rather than new RPC /v1/chain/send_transaction2?returnFailureTrace
: return partial traces on failed transactions?retryTrxNumBlocks
: request node to retry transaction until in a block of given height, blocking call?retryIrreversible
: request node to retry transaction until it is irreversible or expires, blocking call?- If both
blocksBehind
andexpireSeconds
are present, then fetch the block which isblocksBehind
behind head block, use it as a reference for TAPoS, and expire the transactionexpireSeconds
after that block's time.
Parameters
Name | Type |
---|---|
transaction | any |
__namedParameters | Object |
__namedParameters.blocksBehind? | number |
__namedParameters.broadcast? | boolean |
__namedParameters.expireSeconds? | number |
__namedParameters.retryIrreversible? | boolean |
__namedParameters.retryTrxNumBlocks? | number |
__namedParameters.returnFailureTrace? | boolean |
__namedParameters.sign? | boolean |
__namedParameters.useOldRPC? | boolean |
__namedParameters.useOldSendRPC? | boolean |
Returns
Promise
<any
>
node response if broadcast
, {signatures, serializedTransaction}
if !broadcast
Defined in
src/eosjs-api.ts:248